package org.vectrics.user;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;


public class PersonMatchSet extends TreeSet {
	public static final long serialVersionUID = 509432351;
	private Set phoneNumbers = null;
	private PersonNameList names = null;
	private Set emailAddresses = null;
	
	public PersonMatchSet() {
		super(new PersonMatchScoreComparator());
	}

	public PersonMatch findPerson(Person person) {
		PersonMatch result = null;
		Iterator iter = this.iterator();
		while ((result == null) && (iter.hasNext())) {
			PersonMatch current = (PersonMatch)iter.next();
			if (current.getPerson().getId().equals(person.getId())) {
				result = current;
			}
		}
		return(result);
	}
	
	public boolean add(Object object) {
		return super.add((PersonMatch)object);
	}
	
	public boolean add(PersonMatch personMatch) {
		if (findPerson(personMatch.getPerson()) == null)
			return super.add(personMatch);
		else
			return false;
	}

	/**
	 * @return Returns the emailAddresses.
	 */
	public Set getEmailAddresses() {
		return emailAddresses;
	}

	/**
	 * @param emailAddresses The emailAddresses to set.
	 */
	public void setEmailAddresses(Set emailAddresses) {
		this.emailAddresses = emailAddresses;
	}

	
	
	/**
	 * @return Returns the names.
	 */
	public PersonNameList getNames() {
		return names;
	}

	/**
	 * @param names The names to set.
	 */
	public void setNames(PersonNameList names) {
		this.names = names;
	}

	/**
	 * @return Returns the phoneNumbers.
	 */
	public Set getPhoneNumbers() {
		return phoneNumbers;
	}

	/**
	 * @param phoneNumbers The phoneNumbers to set.
	 */
	public void setPhoneNumbers(Set phoneNumbers) {
		this.phoneNumbers = phoneNumbers;
	}

}
